package org.rcy.framework.rpc.monit;

import org.rcy.framework.rpc.NetUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class Health {
	private static Logger logger = LoggerFactory.getLogger(Health.class);
	private String ip; // 服务ip
	private Date time; // 当前时间
	private String result; // json字符串

	public Health() {
		super();
	}

	public Health(String result) {
		super();
		this.result = result;
	}

	public Health(String ip, Date time, String result) {
		super();
		this.ip = ip;
		this.time = time;
		this.result = result;
	}

	public static Health currentHealth(String result) {
		long t1 = System.currentTimeMillis();
		Health health = new Health(NetUtils.getServerIp(), new Date(), result);
		logger.debug("rpc currentHealth cost {}ms",( System.currentTimeMillis()-t1));
		return health;
	}

	public static Health defaultHealth() {
		return currentHealth("OK");
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
}
